#include "StdAfx.h"
#include ".\sectionlock.h"

CKtvSectionLock::CKtvSectionLock(void)
{
	InitializeCriticalSection(&m_cs);
}

CKtvSectionLock::~CKtvSectionLock(void)
{
	DeleteCriticalSection(&m_cs);
}

int CKtvSectionLock::Lock(void)
{
	EnterCriticalSection(&m_cs);
	return 0;
}

int CKtvSectionLock::Unlock(void)
{
	 LeaveCriticalSection(&m_cs);
	return 0;
}

//////////////////////////////////////////////////////////////////////////

CKtvAutoLock::CKtvAutoLock(CKtvSectionLock* lpLock)
{
	m_lpLock = lpLock;
	//if( lpLock )
	//	lpLock->Lock();
}

CKtvAutoLock::~CKtvAutoLock()
{
	//if( m_lpLock )
	//	m_lpLock->Unlock();

	m_lpLock = NULL;
}